/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VisualizarImagenDescargada.java
 *
 * Created on 26/02/2012, 03:11:35 PM
 */

package proy1sistdistribuidos.interfaz;

import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import proy1sistdistribuidos.modelo.ControladorProySistDistribuidos;

/**
 * @author Carlos Diaz Maya, Juan Felipe Garcia
 */
public class VisualizarImagenDescargada extends javax.swing.JFrame {
    private ArrayList infoFila;
    private ControladorProySistDistribuidos cont;
    private VisualizarImagenesDescargadas formPadre;

    /** Creates new form VisualizarImagenDescargada */
    public VisualizarImagenDescargada() {
        initComponents();

    }

    VisualizarImagenDescargada(ArrayList fila, ControladorProySistDistribuidos cont, VisualizarImagenesDescargadas aThis) throws Exception  {
        initComponents();
        this.infoFila=fila;
        this.cont = cont;
        this.formPadre = aThis;
        llenarDatos();
    }

    public void llenarDatos() throws Exception {

        this.jLabelMostrarEtiqueta.setText((String)this.infoFila.get(0));
        this.jLabelMostrarFechaCreacion.setText((String)this.infoFila.get(1));
        this.jLabelMostrarFechaDescarga.setText((String)this.infoFila.get(2));
        this.jLabelNombresPersonas.setText((String)this.infoFila.get(3));

        File archivo = new File((String)this.infoFila.get(4));
        BufferedImage imgbuf = ImageIO.read(archivo);
        int ancho = imgbuf.getWidth();
        int alto = imgbuf.getHeight();
        Icon img = new ImageIcon(imgbuf);

        this.jLabelImagen.setIcon(img);
        this.jLabelImagen.setSize(ancho, alto);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabelMostrarEtiqueta = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabelMostrarFechaCreacion = new javax.swing.JLabel();
        jLabelMostrarFechaDescarga = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jLabelImagen = new javax.swing.JLabel();
        jLabelNombresPersonas = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(proy1sistdistribuidos.interfaz.Principal.class).getContext().getResourceMap(VisualizarImagenDescargada.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setMinimumSize(new java.awt.Dimension(800, 600));
        setName("Form"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabelMostrarEtiqueta.setText(resourceMap.getString("jLabelMostrarEtiqueta.text")); // NOI18N
        jLabelMostrarEtiqueta.setName("jLabelMostrarEtiqueta"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabelMostrarFechaCreacion.setText(resourceMap.getString("jLabelMostrarFechaCreacion.text")); // NOI18N
        jLabelMostrarFechaCreacion.setName("jLabelMostrarFechaCreacion"); // NOI18N

        jLabelMostrarFechaDescarga.setText(resourceMap.getString("jLabelMostrarFechaDescarga.text")); // NOI18N
        jLabelMostrarFechaDescarga.setName("jLabelMostrarFechaDescarga"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jLabelImagen.setText(resourceMap.getString("jLabelImagen.text")); // NOI18N
        jLabelImagen.setName("jLabelImagen"); // NOI18N
        jScrollPane2.setViewportView(jLabelImagen);

        jLabelNombresPersonas.setText(resourceMap.getString("jLabelNombresPersonas.text")); // NOI18N
        jLabelNombresPersonas.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        jLabelNombresPersonas.setName("jLabelNombresPersonas"); // NOI18N

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(12, 12, 12)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabelMostrarFechaCreacion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabelMostrarEtiqueta, javax.swing.GroupLayout.DEFAULT_SIZE, 812, Short.MAX_VALUE)))
                            .addGroup(layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabelNombresPersonas, javax.swing.GroupLayout.DEFAULT_SIZE, 814, Short.MAX_VALUE)
                                    .addComponent(jLabelMostrarFechaDescarga, javax.swing.GroupLayout.DEFAULT_SIZE, 814, Short.MAX_VALUE))))
                        .addGap(19, 19, 19))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel2))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(435, 435, 435)
                        .addComponent(jButton1))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 921, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabelMostrarEtiqueta))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabelMostrarFechaCreacion))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelMostrarFechaDescarga))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabelNombresPersonas, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 689, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(44, 44, 44)
                .addComponent(jButton1)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        this.dispose();
        this.formPadre.setVisible(true);

    }//GEN-LAST:event_jButton1ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VisualizarImagenDescargada().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabelImagen;
    private javax.swing.JLabel jLabelMostrarEtiqueta;
    private javax.swing.JLabel jLabelMostrarFechaCreacion;
    private javax.swing.JLabel jLabelMostrarFechaDescarga;
    private javax.swing.JLabel jLabelNombresPersonas;
    private javax.swing.JScrollPane jScrollPane2;
    // End of variables declaration//GEN-END:variables

}
